//
//  SCWishCell.m
//  Mutal
//
//  Created by TonyStart on 16/10/21.
//  Copyright © 2016年 com.wx. All rights reserved.
//

#import "SCWishCell.h"
#import <UIImageView+WebCache.h>
#import "NSString+SCTimeConvert.h"
@interface SCWishCell() 
@property (weak, nonatomic) IBOutlet UIImageView *wishPicView;
@property (weak, nonatomic) IBOutlet UILabel *wishTitlelabel;
@property (weak, nonatomic) IBOutlet UILabel *wishAddTimeLabel;
@property (weak, nonatomic) IBOutlet UILabel *wishRewardNumLabel;
@property (weak, nonatomic) IBOutlet UIProgressView *progressView;
@property (weak, nonatomic) IBOutlet UILabel *wishUserNameLabel;
@property (weak, nonatomic) IBOutlet UILabel *haveRewardPriceLabel;
@property (weak, nonatomic) IBOutlet UILabel *wishRewardPersonNumLabel;
@property (weak, nonatomic) IBOutlet UILabel *wishRewardTotalLabel;
@property (weak, nonatomic) IBOutlet UILabel *percentageLabel;

@end

@implementation SCWishCell

- (void)awakeFromNib {
    [super awakeFromNib];
    
}

-(void)setWishModel:(SCWishModel *)wishModel{
    _wishModel = wishModel;
    
    if(_wishModel){
        [self setupWishContent];
    }
    
}

-(void)setupWishContent{
    NSString *picUrl = [NSString stringWithFormat:@"http://www.scxxhs.com/huzhu%@",self.wishModel.avatar];
    
    [self.wishPicView sd_setImageWithPreviousCachedImageWithURL:[NSURL URLWithString:picUrl] placeholderImage:[UIImage imageNamed:@"默认头像"] options:SDWebImageRefreshCached progress:^(NSInteger receivedSize, NSInteger expectedSize) {
        
    } completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
        
    }];
    
    self.wishUserNameLabel.text = self.wishModel.user_nicename;
    
    self.wishTitlelabel.text = self.wishModel.wish_title;
    
    self.wishAddTimeLabel.text =  [NSString getShowDateWithTime:self.wishModel.wish_add_time];
    
    self.wishRewardNumLabel.text = self.wishModel.wish_reward_num;
    
    CGFloat haveRewardPrice = round([self.wishModel.wish_reward_price doubleValue]);
    CGFloat totalPrice = [self.wishModel.wish_price doubleValue];
    
    
    CGFloat percentageValue = haveRewardPrice / totalPrice;
    self.progressView.progress = percentageValue;
    
    self.percentageLabel.text = [NSString stringWithFormat:@"%0.0lf%%",percentageValue*100];
    
    self.haveRewardPriceLabel.text =[NSString stringWithFormat:@"已打赏¥%0.0lf",round([self.wishModel.wish_reward_price doubleValue])] ;
    
    self.wishRewardPersonNumLabel.text = [NSString stringWithFormat:@"打赏人数%@",self.wishModel.wish_reward_num];
    
    self.wishRewardTotalLabel.text = [NSString stringWithFormat:@"求打赏%ld",[self.wishModel.wish_price integerValue]];
}


@end
